import React from 'react'
import styles from './index.module.css'
import http from '../../utils/http'
import { useLocation } from 'react-router-dom'
import { SubmitBar } from 'react-vant';

function Index() {
  const { state } = useLocation()
  console.log(state);

  const onSubmit = async () => {
    const res = await http.get('/api/pay', {
      params: {
        title: '支付成功',
        id: state.id,
        price: state.tick?.vip
      }
    })

    console.log(res);

    const {code,data} = res.data

    if(code===200){
      window.location.href = data
    }
    
  }

  return (
    <div>
      <div className={styles.box_wroe}>
        <div className={styles.left_wroe}>
          <span>{state.start}</span>
          <span>{state.startTime}</span>
          <span>{state.end}</span>
          <span>商务座<b>有票</b></span>
          <span>一等座<b>有票</b></span>
          <span>二等座<b>有票</b></span>
        </div>
        <div className={styles.right_wroe}>
          {state.tick?.vip}
        </div>
      </div>
      <SubmitBar price="3050" buttonText="提交订单" onSubmit={() => onSubmit()} />
    </div>
  )
}

export default Index
